<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input id="id" name="id" th:value="${productChannelRelationship.id}" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">产品名称：</label>
                            <div class="col-sm-8">
                                <input id="productname" name="productname"
                                       th:value="${productChannelRelationship.productname}" class="form-control"
                                       type="text" readonly="readonly">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">链接名称：</label>
                            <div class="col-sm-8">
                                <input onkeyup="value=value.replace(/[^\w\.\/]/ig,'')"
                                       maxlength="30" id="linkname"
                                       th:value="${productChannelRelationship.linkname}"
                                       name="linkname" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否模板：</label>
                            <div class="col-sm-8">
                                <select id="ischanneltemplate" name="ischanneltemplate"
                                        class="form-control">
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <input id="ischanneltemplatehidden" name="ischanneltemplatehidden"
                               th:value="${productChannelRelationship.ischanneltemplate}" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">产品状态：</label>
                            <div class="col-sm-8">
                                <select id="state" name="state"
                                        class="form-control">
                                    <option value="1">正常</option>
                                    <option value="0">删除</option>
                                </select>
                            </div>
                        </div>
                        <input id="statehidden" name="statehidden"
                               th:value="${productChannelRelationship.state}" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">选择产品模板：</label>
                            <div class="col-sm-8">
                                <select id="productidischanneltemplate" name="productidischanneltemplate"
                                        class="form-control" type="text"></select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">结算方式：</label>
                            <div class="col-sm-8">
                                <select th:field="${productChannelRelationship.settlementmethod}"
                                        th:value="${productChannelRelationship.settlementmethod}"
                                        onchange="getControlquantity()"
                                        id="settlementmethod" name="settlementmethod"
                                        class="form-control">
                                    <option value="1" th:selected="${productChannelRelationship.settlementmethod=='1'}">
                                        UV
                                    </option>
                                    <option value="2" th:selected="${productChannelRelationship.settlementmethod=='2'}">
                                        CPM
                                    </option>
                                    <option value="3" th:selected="${productChannelRelationship.settlementmethod=='3'}">
                                        CPS
                                    </option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group" id="aaaaaa">
                            <label class="col-sm-3 control-label">刊例价格：</label>
                            <div class="col-sm-8">
                                <input onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
                                       onafterpaste="this.value=this.value.replace(/[^\d.]/g,'')"
                                       maxlength="12" id="settlementprice"
                                       name="settlementprice" class="form-control"
                                       th:value="${productChannelRelationship.settlementprice}"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group" id="bbbbbb">
                            <label class="col-sm-3 control-label">结算比例：</label>
                            <div class="col-sm-8">
                                <input onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"
                                       maxlength="10" id="channelsettlementrate"
                                       name="channelsettlementrate"
                                       th:value="${productChannelRelationship.channelsettlementrate}"
                                       type="text" placeholder="渠道分成">：
                                <input onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"
                                       maxlength="10" id="platformsettlementrate"
                                       name="platformsettlementrate"
                                       th:value="${productChannelRelationship.platformsettlementrate}"
                                       type="text" placeholder="平台分成">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-8">
                                <input maxlength="1024"
                                       th:value="${productChannelRelationship.description}" id="description"
                                       name="description" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/appjs/market/productChannelRelationship/edit.js">
</script>
<script type="text/javascript" th:inline="javascript">
    $(function () {
        var ischanneltemplatehidden = $('#ischanneltemplatehidden').val();
        $('#ischanneltemplate').val(ischanneltemplatehidden);
        var statehidden = $('#statehidden').val();
        $('#state').val(statehidden);

        getControlquantity();

    })

    function getControlquantity() {


        var settlementmethod = $("#settlementmethod").val();
        if (settlementmethod == 1 || settlementmethod == 2) {
            $("#aaaaaa").show();
            $("#bbbbbb").hide();
            $("#channelsettlementrate").val('');
            $("#platformsettlementrate").val('');
        } else if (settlementmethod == 3) {
            $("#aaaaaa").hide();
            $("#settlementprice").val('');
            $("#bbbbbb").show();
        } else {
            $("#aaaaaa").hide();
            $("#bbbbbb").hide();
            $("#settlementprice").val('');
            $("#channelsettlementrate").val('');
            $("#platformsettlementrate").val('');
        }
    }
</script>
</body>
</html>
